class TreeNode{
	private TreeNode left;
	private TreeNode right;
//	private Object value;
	private int value;
	
	public TreeNode(TreeNode left, TreeNode right, int value){
		this.left = left;
		this.right = right;
		this.value = value;
	}
	
	public TreeNode getLeft(){
		return left;
	}
	public TreeNode getRight(){
		return right;
	}
	public int getValue(){
		return value;
	}
	
	//find Node by value in BST O(logn)
	public TreeNode findNode(TreeNode root, int value){
		while(root != null){
			int curVal=root.getValue();
			if(curVal == value){
				break;
			} else if (curVal < value){
				root = root.getRight();
			}else {
				root = root.getLeft();
			}
		}
		return root;
	}
	public void printValue(){
		System.out.println("Node's value is "+value);
	}
		
}